<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <style>
        .aui-list .aui-list-item-label,
        .aui-list .aui-list-item-label-icon {
            width: 100%;
        }

        .aui-switch:checked {
            border-color: #fd5454;
            background-color: #fd5454;
        }

        .aui-list .aui-list-item-input {
            text-align: right;
        }

        .aui-list .aui-list-item-input select {
            width: auto;
            display: inline-block;
        }

        .aui-radio:checked,
        .aui-radio.aui-checked,
        .aui-checkbox:checked,
        .aui-checkbox.aui-checked {
            background-color: #fd5454;
            border: solid 1px #fd5454;
        }

        .not-use {
            background: #09ad09;
            color: #ffffff;
            padding: 0.3rem;
            display: inline-block;
            border-radius: 0.3rem;
            font-size: 0.8rem;
        }

        .use-in {
            background: #ff2600;
            color: #ffffff;
            padding: 0.3rem;
            display: inline-block;
            border-radius: 0.3rem;
            font-size: 0.8rem;
        }
    </style>
</head>

<body>
    <div class="vue">
        <div class="loading" v-if="loading"></div>
        <div class="aui-content">

            <div v-if="!list.length" style="text-align:center;font-size:1rem;margin-top:3rem">没有管理项目</div>

            <!-- 餐饮 -->
            <ul class="aui-list aui-form-list" v-if="cate_name=='goods'">
                <li class="aui-list-item" v-for="(item,index) in list">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">{{item.seatname}}</div>
                        <div class="aui-list-item-input">
                            <span class="not-use" @click="changeStatus(item,'seatid','seatstatus',index)" v-if="item.seatstatus==1">未使用</span>
                            <span class="use-in" @click="changeStatus(item,'seatid','seatstatus',index)" v-else>使用中</span>
                        </div>
                    </div>
                </li>
            </ul>

            <!-- 酒店 -->
            <ul class="aui-list aui-form-list" v-if="cate_name=='hotel'">
                <li class="aui-list-item" v-for="(item,index) in list">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">{{item.room_type}}</div>
                        <div class="aui-list-item-input">
                            <span class="not-use" @click="changeStatus(item,'room_id','room_status',index)" v-if="item.room_status==0">可预订</span>
                            <span class="use-in" @click="changeStatus(item,'room_id','room_status',index)" v-else>已订满</span>
                        </div>
                    </div>
                </li>
            </ul>

            <!-- KTV -->
            <ul class="aui-list aui-form-list" v-if="cate_name=='KTV'">
                <li class="aui-list-item" v-for="(item,index) in list">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">{{item.room_type}}</div>
                        <div class="aui-list-item-input">
                            <span class="not-use" @click="changeStatus(item,'ktv_id','room_status',index)" v-if="item.room_status==0">可预订</span>
                            <span class="use-in" @click="changeStatus(item,'ktv_id','room_status',index)" v-else>已订满</span>
                        </div>
                    </div>
                </li>
            </ul>

            <!-- 养生 -->
            <ul class="aui-list aui-form-list" v-if="cate_name=='health'">
                <li class="aui-list-item" v-for="(item,index) in list">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">{{item.room_type}}</div>
                        <div class="aui-list-item-input">
                            <span class="not-use" @click="changeStatus(item,'health_id','room_status',index)" v-if="item.room_status==0">可预订</span>
                            <span class="use-in" @click="changeStatus(item,'health_id','room_status',index)" v-else>已订满</span>
                        </div>
                    </div>
                </li>
            </ul>

            <!-- 景点 -->
            <ul class="aui-list aui-form-list" v-if="cate_name=='scenic'">
                <li class="aui-list-item" v-for="(item,index) in list">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">{{item.scenic_type}}</div>
                        <div class="aui-list-item-input">
                            <span class="not-use" @click="changeStatus(item,'scenic_id','scenic_status',index)" v-if="item.scenic_status==0">可预订</span>
                            <span class="use-in" @click="changeStatus(item,'scenic_id','scenic_status',index)" v-else>已订满</span>
                        </div>
                    </div>
                </li>
            </ul>

            <!-- 其他 -->
            <ul class="aui-list aui-form-list" v-if="cate_name=='other'">
                <li class="aui-list-item" v-for="(item,index) in list">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">{{item.name}}</div>
                        <div class="aui-list-item-input">
                            <span class="not-use" @click="changeStatus(item,'id','status',index)" v-if="item.status==0">可预订</span>
                            <span class="use-in" @click="changeStatus(item,'id','status',index)" v-else>已订满</span>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    <script type="text/javascript" src="../script/vue.js"></script>
    <script type="text/javascript" src="../script/base64.js"></script>
    <script type="text/javascript" src="../script/app.js"></script>
    <script type="text/javascript">
        apiready = function() {
            api.setRefreshHeaderInfo({
                loadingImg: 'widget://image/refresh.png',
                bgColor: '#f8f8f8',
                textColor: '#505050',
                textDown: '下拉刷新...',
                textUp: '松开刷新...'
            }, function(ret, err) {
                Ve.getList(function() {
                    Ve.list = [];
                    api.refreshHeaderLoadDone();
                })
            });

            var Ve = new Vue({
                el: '.vue',
                data: {
                    loading: true,
                    cate_name: '',
                    user: api.pageParam,
                    list: []
                },
                methods: {
                    getList: function(callback) {
                        app.request.post('/myhome/business_control', {
                            business_id: this.user.business_id,
                            signature: app.sign(this.user.business_id),
                        }, {}, function(res) {
                            // console.log(JSON.stringify(res))
                            callback && callback()
                            if (res.code == 1) {
                                Ve.cate_name = res.cate_name
                                for (var i in res.data) {
                                    Ve.list.push(res.data[i])
                                }
                            } else {
                                app.error(res.msg);
                            }
                            app.loadingFinish(Ve)
                        })
                    },
                    changeStatus: function(item, id, status, index) {
                        app.request.post('/myhome/changeRoomStatus', {
                            id: item[id],
                            cate_name: this.cate_name,
                            signature: app.sign(item[id])
                        }, {}, function(res) {
                            if (res.code == 1) {
                                Ve.list[index][status] = (item[status] == 1) ? 0 : 1
                            } else {
                                app.error(res.msg)
                            }
                        })
                    }
                },
                created: function() {
                    this.getList()
                }
            })
        }
    </script>
</body>

</html>
